package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.WriteOffRecordDao;
import com.xbongbong.saas.domain.entity.WriteOffRecordEntity;
import com.xbongbong.saas.model.WriteOffRecordModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

;

/**
 * @author bomfish
 */
@Service("writeOffRecordModel")
public class WriteOffRecordModelImpl implements WriteOffRecordModel {
    @Resource
    private WriteOffRecordDao writeOffRecordDao;

    @Override
    public Long insert(WriteOffRecordEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        entity.setDel(DelEnum.NORMAL.getDel());
        return writeOffRecordDao.insert(entity);
    }

    @Override
    public void insertBatch(List<WriteOffRecordEntity> list) {
        writeOffRecordDao.insertBatch(list);
    }

    @Override
    public List<WriteOffRecordEntity> findEntities(Map<String, Object> param) {
        return writeOffRecordDao.findEntities(param);
    }

    @Override
    public Integer getEntityCount(Map<String, Object> param) {
        return writeOffRecordDao.getEntitiesCount(param);
    }

    @Override
    public void update(WriteOffRecordEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        writeOffRecordDao.update(entity);
    }

    @Override
    public WriteOffRecordEntity getByKey(Long key, String corpid) {
        return writeOffRecordDao.getByKey(key, corpid);
    }

}
